import fs from 'node:fs'
const files = fs.readdirSync('./plugins/panel-plugin/apps').filter(file => file.endsWith('.js'))

let ret = []
logger.info(`_______(σﾟ∀ﾟ)σ..:*☆______`);
logger.info(`面板插件加载完毕~`)
logger.info(`仓库地址：https://gitee.com/CUZNIL/panel-plugin`);
logger.info(`插件/BOT交流群：638077675`);
logger.info(`帮助指令：#面板操作帮助`);
logger.info(`_______ヾ(o´∀｀o)ﾉ _______`);


files.forEach((file) => {
    ret.push(import(`./apps/${file}`))
})

ret = await Promise.allSettled(ret)

let apps = {}
for (let i in files) {
    let name = files[i].replace('.js', '')

    if (ret[i].status != 'fulfilled') {
        logger.error(`载入插件错误：${logger.red(name)}`)
        logger.error(ret[i].reason)
        continue
    }
    apps[name] = ret[i].value[Object.keys(ret[i].value)[0]]
}
export { apps }
